package com.blockmeta.bbs.baselibrary.widget.dialog;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;

import com.blockmeta.bbs.baselibrary.R;

/**
 * @author AirThor
 * @date 2019/5/7.
 */
public class HintDialog extends RxDialogSureCancel implements View.OnClickListener{
    private OnSureCallback mOnSureCallback;

    public void setOnSureCallback(OnSureCallback onSureCallback) {
        mOnSureCallback = onSureCallback;
    }

    public HintDialog(Context context, int themeResId) {
        super(context, themeResId);
    }

    public HintDialog(Context context, boolean cancelable, DialogInterface.OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public HintDialog(Context context) {
        super(context);
    }

    public HintDialog(Activity context) {
        super(context);
    }

    public HintDialog(Context context, float alpha, int gravity) {
        super(context, alpha, gravity);
    }

    @Override
    protected void initView() {
        super.initView();
        getCancelView().setOnClickListener(this);
        getSureView().setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        int i = v.getId();
        if (i == R.id.tv_cancle) {
            if (isShowing()) {
                dismiss();
            }
        } else if (i == R.id.tv_sure) {
            if (mOnSureCallback != null) {
                mOnSureCallback.onSureCallback();
            }
        }
    }

    public interface OnSureCallback{
        void onSureCallback();
    }
}
